package ua.races.jsptag;

import org.apache.log4j.Logger;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.TagSupport;
import java.io.IOException;

public class LogoutTag extends TagSupport {

    private static final Logger log = Logger.getLogger(LogoutTag.class.getName());

    private String text;

    public void setText(String text) {
        this.text = text;
    }

    public int doStartTag() throws JspException {

        JspWriter w = pageContext.getOut();
        try {
            w.println("<div style=\"text-align: right;\">[<a href=\"logout.do\">" +
                    text +
                    "</a>]</div>");
        } catch (IOException
                e) {
            log.error(e);
        }

        return SKIP_BODY;

    }

    public int doEndTag
            () throws JspException {
        return EVAL_PAGE;
    }
}